﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using KPIS.GERP.GHRMS.DAL;
using KPIS.GERP.GHRMS.DALFactory;
using KPIS.GERP.GHRMS.IDAL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;

namespace KPIS.GERP.GHRMS.BLL
{
    public sealed class MasEducationMajorBLL : IMasEducationMajorBLL
    {
        private static readonly IMasEducationMajorDAL dal = DataAccess.CreateMasterEducationMajor();
        private MasEducationMajorInfo info = new MasEducationMajorInfo();
        public IList<MasEducationMajorInfo> ListEducationMajors()
        {
            return dal.ListEducationMajors(new MasEducationMajorInfo(0));
        }
        public IList<MasEducationMajorInfo> ListEducationMajors(string Sequence)
        {
            int Seq = Sequence.Length > 0 ? Int32.Parse(Sequence) : 0;

            return dal.ListEducationMajors(new MasEducationMajorInfo(Seq));
        }
        public DataSet LoadEducationMajors(Nullable<int> Sequence, string SearchText)
        {
            int Seq = Sequence.HasValue ? (int)Sequence : 0;
            info.Sequence = Seq;
            info.strFilter = SearchText;

            return dal.LoadEducationMajors(info);
        }
        public void Insert(string Code, string Name, string NameEng, int CreatedBy)
        {
            try
            {
                dal.Insert(new MasEducationMajorInfo(0, Code, Name, NameEng, "", CreatedBy, 0));
            }
            catch 
            {
                throw new Exception("");
            }
        }
        public void Update(int Sequence, string Code, string Name, string NameEng, int UpdatedBy)
        {
            try
            {
                dal.Update(new MasEducationMajorInfo(Sequence, Code, Name, NameEng, "", 0, UpdatedBy));
            }
            catch
            {
                throw new Exception("");
            }
        }
        public void Delete(int Sequence, int UpdatedBy)
        {
            try
            {
                dal.Delete(Sequence, UpdatedBy);
            }
            catch
            {
                throw new Exception("");
            }
        }
    }
}
